﻿namespace CCS.WebApp.ViewModels.Builders.Impl
{
    using System.Linq;
    using CIK.Framework.Diagnostics;
    using CCS.BLL;
    using CCS.BLL.Impl;

    public class HomePageVMBuilder : IHomePageVMBuilder
    {
        private readonly ICategoryManager categoryManager;

        public HomePageVMBuilder()
            : this(new CategoryManager())
        {
        }

        public HomePageVMBuilder(ICategoryManager categoryManager)
        {
            this.categoryManager = categoryManager;
        }

        public HomePageViewModel HomePageVMBuild()
        {
            Throw.IfArgumentNull(this.categoryManager, "CategoryManager");

            var vm = new HomePageViewModel();
            var categories = this.categoryManager.GetAll().ToList();

            vm.Categories = categories;

            return vm;
        }
    }
}